import com.sun.corba.se.impl.logging.POASystemException;
import javafx.geometry.Pos;

import java.nio.file.attribute.PosixFileAttributes;
import java.util.Scanner;

/**
 * @Author @fiber-cloud
 * @Date 2025/7/15 19:10
 */
public class main {
    //noob53 年轻人不讲5的
    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();

        //将5替换成*
        String s1 = s.replace("5","*");
        System.out.println(s1);
    }


    //noob54 斗兽棋
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        String a = in.next(),b = in.next();
        String[][] animal  = {{"mouse","elephant","tiger","cat"},{"elephant","tiger","cat","mouse"},{"tiger","cat","mouse","elephant"}};
        for(int i=1,j=0;j<4;j++)
        {
            if(a.equals(animal[1][j]))
            {
                if(b.equals(animal[i+1][j]))
                {
                    System.out.print("win");
                }
                else if(b.equals(animal[i-1][j]))
                {
                    System.out.print("lose");
                }
                else
                {
                    System.out.print("tie");
                }
            }
        }
    }


    //noob55 BFS
    public static void main3(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();

        String s1 = s.toLowerCase();
        int count = s1.indexOf("bob");
        System.out.println(count);
    }
    //noob56 凯撒加密
    public static void main4(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        String s = sc.next();

        i %= 26;
        StringBuilder s1 = new StringBuilder();

        for (char c : s.toCharArray()) {
            int o = c - 'a';
            int newPos = (o+i)%26;
            char newChar = (char)('a'+newPos);
            s1.append(newChar);
        }
        System.out.println(s1.toString());

    }
    //noob57 无限长正整数排列字符串
    public static void main5(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();

        long digits = 1;
        long count = 9;
        long startNum = 1;

        while (n > digits * count) {
            n -= digits * count;
            digits++;
            count *= 10;
            startNum *= 10;
        }

        long targetNum = startNum + (n - 1) / digits;
        long digitIndex = (n - 1) % digits;

        String sNum = String.valueOf(targetNum);
        System.out.println(sNum.charAt((int)digitIndex));
    }
    //noob58 简写单词
    public static void main6(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] strs = str.split(" ");
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<strs.length; i++){
            sb.append(strs[i].charAt(0)+"");
        }
        System.out.println(sb.toString().toUpperCase());
    }
//    //noob59 牛牛的考试
//    public static void main(String[] args) {
//        Scanner sc = new Scanner(System.in);
//        int n = sc.nextInt();
//        while ((n-- )>= 0){
//            String A = sc.next();
//            String B = sc.next();
//            String C = sc.next();
//            String D = sc.next();
//
//            if (A.length()>B.length())
//        }
//    }
    //noob60 添加逗号
    public static void main7(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();

        StringBuilder sb = new StringBuilder(str);
        for (int i = str.length()-3; i > 0  ; i-=3) {
            sb.insert(i,',');
        }
        System.out.println(sb.toString());
    }
    //noob61 字符串操作
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        String str = scan.next();
        char[] arr = new char[n+1];
        for(int i = 1;i < arr.length;i++) {
            arr[i] = str.charAt(i-1);
        }
        int l = 0, r = 0;
        char c1 = 0, c2 = 0;
        while (m > 0) {
            l = scan.nextInt();
            r = scan.nextInt();
            c1 = scan.next().charAt(0);
            c2 = scan.next().charAt(0);
            for(int i = l;i<=r;i++) {
                if(arr[i]==c1) {
                    arr[i] = c2;
                }
            }
            m--;
        }
        for(int i = 1;i < arr.length;i++) {
            System.out.print(arr[i]);
        }


    }
    //判断是否包含某个元素
    public boolean comtairs (int toFind){
        for (int i = 0; i < this.size(); i++) {
            if (this.array[i] == toFind){
                return true;
            }
        }
        return false;
    }
    //查找某个元素对应的位置
    public int indexOf(int toFind){
        for (int i = 0; i < this.size(); i++) {
            if (this.array[i] == toFind){
                return i;
            }
        }
        return -1;
    }
    //获取pos位置的元素
    public int get(int pos) {
        if (pos < 0 || pos > this.size()){

        }
        return array[pos];
    }
    public void remove(int key){
        if (this.size() == 0){
            return;
        }
        int inde = 0;
        for (int i = 0; i < this.size(); i++) {
            inde = i;
        }
        for (int i = inde; i < this.size()-1; i++) {
            if (array[i] == key){
                array[i] = array[i+1];
            }
        }
        this.usedSize--;
    }


}
